//----------------------------------------------------------------------------
// Filename                : blink_led.c
//
// Functional Description  : LED Blink Support
//----------------------------------------------------------------------------

#include "DRV922XX.h"
#include "message_protocol_application.h"

/*
 *  \fn void blink_led(int led_rate)
 */
#define BLINK_RATE	BLINK_RATE_MIN
#define BLINK_RATE_MAX	65535
#define BLINK_RATE_MIN	1000
/*
 *  \fn void blink_led(int led_rate)
 *  Blink LED at given rate. Will loop continuously. If brake button is pressed, will reset device via PUC (not POR)
 *  \param led_rate 2 for slow blink, 8 for fast
 */
void blink_led(unsigned int led_rate)
{
	volatile unsigned int i, j;
	
	while (1)
	{
		for (i = 0; i < BLINK_RATE; i++)
		{
			for (j = 0; j < led_rate; j++)
			{
				if (getBrakeState() == BRAKE_ON)
				//if ((P4IN & 0x20) == 0)
					WDTCTL = 0xDEAD;
			}
		} 
			
		P2OUT ^= BIT0;
	}
}
